package myplaydog.qf.com.yimixianproject.customview;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

import myplaydog.qf.com.yimixianproject.listener.ScrollViewListener;

/**
 * Created by guqiang on 2016/9/29.
 * User: guqiang
 * Date: 2016/9/29
 * Email:xxxx@163.com
 * Project: ScrollViewTest
 */
public class ObservableScrollView extends ScrollView {

    private ScrollViewListener scrollViewListener = null;

    public ObservableScrollView(Context context) {
        super(context);
    }

    public ObservableScrollView(Context context, AttributeSet attrs,
                                int defStyle) {
        super(context, attrs, defStyle);
    }

    public ObservableScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void setScrollViewListener(ScrollViewListener scrollViewListener) {
        this.scrollViewListener = scrollViewListener;
    }

    @Override
    protected void onScrollChanged(int x, int y, int oldx, int oldy) {
        super.onScrollChanged(x, y, oldx, oldy);
        if (scrollViewListener != null) {
            scrollViewListener.onScrollChanged(this, x, y, oldx, oldy);
        }
    }
}
